package com.hzya.frame.utils.help;

import org.jasypt.util.text.BasicTextEncryptor;

/***
 * 配置文件加密demo
 * @author 郭军辉
 *
 * 2018年1月26日上午10:40:55
 */
public class PropertiesEncryption {
	public static void main(String[] args) {
	    /**
	     * setPassword("hzya"); 			设置加密戳
	     * textEncryptor.encrypt("123456")  设置加密的密码
	     */
        BasicTextEncryptor textEncryptor = new BasicTextEncryptor();     
        textEncryptor.setPassword("hzya");    
        String newPassword = textEncryptor.encrypt("123456");    
        System.out.println(newPassword);    
        /**
	     * setPassword("hzya"); 			设置解密戳
	     * decrypt(newPassword)  			设置解密的密文
	     */
        BasicTextEncryptor textEncryptor2 = new BasicTextEncryptor();     
        textEncryptor2.setPassword("hzya");     
        String oldPassword = textEncryptor2.decrypt(newPassword);       
        System.out.println(oldPassword);    
        System.out.println("--------------------------");  
	}
}
